package com.bdqn.qnnews.common.base;

import lombok.Data;
import lombok.experimental.Accessors;

/**
 * 统一分页对象
 * @author xlzhang
 */
@Data
// 链式语法
@Accessors(chain = true)
public final class PageResult<T> {
    private Integer code;
    private String errorMessage;
    private T data;
    private Integer currentPage;
    private Integer size;
    private Integer total;

    public static<T> PageResult<T> ok(ResultCode resultCode, T data){
        final PageResult<T> r = new PageResult<>();
        r.setCode(resultCode.code);
        r.setErrorMessage(resultCode.errorMessage);
        r.setData(data);
        return r;
    }
}
